﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace JavaBatGenerator
{
    public partial class frmGenerator : Form
    {
        public frmGenerator(string[] files)
        {
            InitializeComponent();
            int index = 0;
            _files = files;
            SelectedFiles = new List<string>();
            foreach (var item in files)
            {
                clbFiles.Items.Add(Path.GetFileName(item) + " - (" + item + ")");
                clbFiles.SetItemChecked(index, true);
                SelectedFiles.Add(item);
                ++index;
            }
            clbFiles.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.clbFiles_ItemCheck);
        }

        private string[] _files;

        public List<string> SelectedFiles { get; private set; }

        private void clbFiles_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (e.NewValue == CheckState.Checked && !SelectedFiles.Contains(_files[e.Index]))
            {
                SelectedFiles.Add(_files[e.Index]);
            }
            else
            {
                if (e.NewValue == CheckState.Unchecked && SelectedFiles.Contains(_files[e.Index]))
                {
                    SelectedFiles.Remove(_files[e.Index]);
                }
            }
        }
    }
}
